home *** CD-ROM | disk | FTP | other *** search
/ Learn Microsoft Visual Basic 6.0 Now / Learn Microsoft Visual Basic 6.0 Now (Microsoft Press)(X03-58607)(1998).ISO / media / chap02 / b02d010.cc2 < prev    next >
Text File  |  1998-06-07  |  4KB  |  86 lines

  1. 0, The program I'll create in this 
  2. 2, demonstration is a bitmap browser, a tool you 
  3. 4, can use to explore the bitmap files on 
  4. 6, your system. To build a bitmap browser I'll 
  5. 9, create a drive listbox object, a 
  6. 13, directory listbox object, a file listbox 
  7. 16, object, and an imagebox object. And I'll link 
  8. 19, the four of them together with program 
  9. 21, code. So, to get started I'll click the 
  10. 24, drive listbox object on my toolbox and 
  11. 27, go to the form and drag to create a drive 
  12. 31, listbox object on the form. And I can 
  13. 34, resize it with the selection handles. And 
  14. 36, then I can click a directory listbox 
  15. 38, object and drag to create it on my form. 
  16. 42, And as you can see in both cases 
  17. 44, information fills those so I can size them 
  18. 47, correctly. And I'll use the file listbox 
  19. 50, object to create a file listbox object on my form, 
  20. 53, and it fills with file names. Now I'll 
  21. 56, click the imagebox object and drag to 
  22. 59, create an imagebox on my form. And just 
  23. 62, like that I have the four elements of my 
  24. 64, user interface. Now I'll click the file 
  25. 67, listbox object and scroll down in the 
  26. 70, properties window to the pattern property. 
  27. 75, And I'll change that to *.bmp; *.wmf; and 
  28. 83, *.ico with a semicolon inbetween each 
  29. 86, entry so that Windows metafiles, and 
  30. 89, bitmaps, and icons will appear when the 
  31. 92, dialog box appears to list those files. Then 
  32. 97, I'll go to the imagebox object and 
  33. 100, scroll down to the stretch property and set 
  34. 102, that to true so that large bitmap files 
  35. 105, will shrink down to the image object and 
  36. 110, tiny bitmap files will stretch out to 
  37. 113, fill the entire imagebox object. That 
  38. 115, will make it have a consistent look. And to 
  39. 117, give it a bit of a 3-D appearance I'll 
  40. 119, go up to the top of the properties 
  41. 121, window and select border style and select 
  42. 124, fixed single. And that'll give it a 3-D 
  43. 126, look. Now let's continue to customize our 
  44. 130, objects with program code. First, I'll 
  45. 133, double-click the drive listbox object, and 
  46. 137, in that event procedure I'll type 
  47. 139, dir1.Path = Drive1. Drive. This code updates 
  48. 151, the path property in the directory 
  49. 154, listbox when the user selects a drive in the 
  50. 157, drive listbox. Now I'll go to my 
  51. 160, dropdown listbox and select the directory 
  52. 162, listbox object. And in here I'll type file1. 
  53. 171, path = dir1.Path. And that links the 
  54. 179, file listbox to the directory listbox. 
  55. 183, Finally, I'll click the file 1 object and 
  56. 186, type the two important, really important 
  57. 189, lines in my program code here. I'll type 
  58. 195, SelectedFile, a variable, and I'll 
  59. 199, assign that file 1.Path and the backslash 
  60. 205, character and the File 1.File name 
  61. 216, property. And then I'll use that variable in the 
  62. 220, following statement. 
  63. 225, Image1.Picture=LoadPicture, and then SelectedFile. What the 
  64. 235, statement does is, with the 
  65. 237, SelectedFile variable builds a complete Path name 
  66. 241, using the file listbox object, a 
  67. 244, backslash character, and then the file listbox 
  68. 248, object. And then it loads it into the 
  69. 252, picture property of the Image1 object with 
  70. 255, the LoadPicture function, which uses the 
  71. 260, selected file variable we created in 
  72. 262, the program statement above. Okay, now 
  73. 265, let's go ahead and run this program in the 
  74. 267, programming environment and see what it 
  75. 269, looks like. As you can see, the four 
  76. 271, elements of our form appear and I can click 
  77. 275, drive C, where I have some files loaded 
  78. 278, and we can go to the LVB6 Chapter 2 
  79. 281, folder. And in this folder we have a number 
  80. 284, of file names that I can click. My 
  81. 287, listbox is complete with scroll bars because 
  82. 291, there's a long list. And as you can 
  83. 293, see, each one of them appears as soon as I 
  84. 295, single-click it. And that's my event 
  85. 298, procedure at work.
  86. 300, END